﻿<phone:PhoneApplicationPage 
    x:Class="Ben.LircSharp.Phone.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <controls:Pivot Title="LIRC Remote">
            <controls:PivotItem Header="all" Margin="12,0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <toolkit:ListPicker x:Name="RemoteListPicker" Header="remote" ItemsSource="{Binding Remotes}" 
                                        SelectedItem="{Binding SelectedRemote, Mode=TwoWay}" SelectionMode="Single" 
                                        Grid.Row="0"/>

                    <TextBlock x:Name="Status" Text="{Binding Status}" TextAlignment="Right" Style="{StaticResource PhoneTextSubtleStyle}" Grid.Row="1" VerticalAlignment="Bottom"/>
                    
                    <toolkit:LongListSelector x:Name="CommandListPicker" Grid.Row="1" IsFlatList="True" toolkit:TiltEffect.IsTiltEnabled="True"
                                              ItemsSource="{Binding SelectedRemoteCommands}" Background="Transparent">
                        <toolkit:LongListSelector.GroupHeaderTemplate>
                            <DataTemplate>
                                <Border Background="{StaticResource PhoneAccentBrush}">
                                    <TextBlock Text="{Binding Key}" Foreground="{StaticResource PhoneForegroundBrush}" Margin="3,12,3,3" />
                                </Border>
                            </DataTemplate>
                        </toolkit:LongListSelector.GroupHeaderTemplate>
                        <toolkit:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <Border>
                                    <TextBlock Text="{Binding}" Tap="CommandListPicker_Tap" Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="{StaticResource PhoneTouchTargetOverhang}"/>
                                </Border>
                            </DataTemplate>
                        </toolkit:LongListSelector.ItemTemplate>
                    </toolkit:LongListSelector>
                </Grid>
            </controls:PivotItem>
 
            <controls:PivotItem Header="custom" x:Name="RemotePivot" Content="{Binding RemotePanel}" Margin="12,0"> 
                
            </controls:PivotItem>
            
            <controls:PivotItem Header="log" Margin="12,0">
                <!--<ListBox x:Name="LogMessages" ItemsSource="{Binding LogLines}" />-->
                <ScrollViewer>
                    <TextBlock x:Name="RawLogMessages" Text="{Binding RawLog}" TextWrapping="Wrap"/>
                </ScrollViewer>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>
 
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar.settings.png" Text="Settings" Click="Settings_Click"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar.refresh.png" Text="Refresh" Click="Refresh_Click"/>
            <shell:ApplicationBarIconButton IconUri="/Toolkit.Content/ApplicationBar.Cancel.png" Text="Clear Log" Click="ClearLog_Click"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Reload Custom Remote Layout" Click="ReloadLayout_Click"/>
                <!--<shell:ApplicationBarMenuItem Text="MenuItem 2"/>-->
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>